﻿@using Topro.Entity.Enum;
@{
    Layout = "~/Views/Shared/_Dialog.cshtml";
}
@model Topro.Entity.Response.User.UserResponse
<section class="container-fluid" style="background-color: white;">
    <form class="form-horizontal m15_t" id="form">
        <div class="tab-content">
            <input type="hidden" id="rId" name="rId" value="0">
            <div class="tab-pane fade in active" id="home">
                <div class="form-group">
                    <label class="wd100 control-label">登陆名称：</label>
                    <div class="wd250">
                        <label class=" m10_t">@(Model.Account)</label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>旧密码：</label>
                    <div class="input-group wd250">
                        <input class="form-control" type="password" name="oldPassWord" maxlength="20" placeholder="长度必须介于 6 和 20 之间" autocomplete="off" />
                        <span class="input-group-addon" style="margin-left:20px;" onclick="changeInputType(this);">
                            <i class="glyphicon glyphicon-eye-open"></i>
                        </span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>新密码：</label>
                    <div class="input-group wd250 m15_l">
                        <input class="form-control" type="password" name="newPassWord" id="newPassWord" maxlength="40" autocomplete="off" placeholder="长度必须介于 6 和 40 之间">
                        <span class="input-group-addon" style="margin-left:20px;" onclick="changeInputType(this);">
                            <i class="glyphicon glyphicon-eye-open"></i>
                        </span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>确认新密码：</label>
                    <div class="input-group wd250 m15_l">
                        <input class="form-control" type="password" name="confirmNewPassWord" maxlength="40" autocomplete="off" placeholder="长度必须介于 6 和 40 之间">
                        <span class="input-group-addon" style="margin-left:20px;" onclick="changeInputType(this);">
                            <i class="glyphicon glyphicon-eye-open"></i>
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </form>
</section>
@section footerScript{
    <script type="text/javascript">

        function changeInputType(obj) {

            var that = $(obj).prev();
            if (that.attr('type') == 'text') {
                that.attr('type', 'password');
                $(obj).find("i").removeClass("glyphicon-eye-open");
                $(obj).find("i").addClass("glyphicon-eye-close");
            } else {
                that.attr('type', 'text');
                $(obj).find("i").removeClass("glyphicon-eye-close");
                $(obj).find("i").addClass("glyphicon-eye-open");
            }

        }

        function save() {

            var user = $("#form").serializeJSON();

            var cover = Topro.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            Topro.Util.Ajax({
                type: "POST",
                url: "/Home/ResetPassWord",
                data: { request: user },
                success: function (res) {
                    if (res.success) {
                        cover.Remove();
                        Topro.UI.DialogOpener().Tip_success("操作成功！");
                        Topro.UI.CloseDialog();
                    } else {
                        cover.Remove();
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    cover.Remove();
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

        }
    </script>
}